package com.pactera.wh.druid.common;

import com.baomidou.mybatisplus.extension.api.R;
import lombok.Data;

import java.io.Serializable;

/**
 * <p>
 *
 * </p>
 *
 * @author chang.zhou
 * @version 1$
 * @date Created in 2020/8/25 17:28
 */
@Data
public class RestBody<T> implements Rest<T>, Serializable {
    private int code = 2000;
    private T data;
    private String message;

    private RestBody() {
    }

    private RestBody(T data) {
        this.data = data;
    }

    private RestBody(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public static RestBody<?> ok(){
        return new RestBody<>();
    }

    public static <T> RestBody<T> ok(T data){
        return new RestBody<>(data);
    }

    public static RestBody<?> fail(int code,String message){
        return new RestBody<>(code,message);
    }
}
